﻿using System;
using System.Web.UI;
using System.Text;
using QzEbook.BaseView;
using QzEbook.AccessObject;

namespace qzEbook.webUI
{
    public partial class ShowView :UserPage
    {
        private int bookId;
        private bool viewType = false;
        protected void Page_Load(object sender, EventArgs e)
        {
            bookId = int.Parse(Request["Bid"].ToString());
            Book book = new Book();
            book.BookId = bookId;
            book=book.select();
            viewType=book.ViewType;
        }


        public void bulidSWF()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<script language=\"javascript\" type=\"text/javascript\">");
            sb.AppendLine();
            sb.AppendFormat("var xmlPath=\"../GetConfig.aspx?Bid={0}\";", bookId);
            sb.AppendLine();
            sb.AppendLine("var crlnet='crlnet'");
            if (viewType)
            {
                sb.AppendFormat("var so = new SWFObject('QzReader/singlepage.swf',crlnet , '100%', '400', '8', '', true);");
            }
            else
            {
                sb.AppendFormat("var so = new SWFObject('QzReader/ipageBook.swf',crlnet , '100%', '400', '8', '', true);");
            }
            sb.AppendLine();

            sb.AppendFormat("so.addParam(\"FlashVars\", \"configxml=\"+xmlPath);");
            sb.AppendLine();
            sb.AppendFormat("so.addParam('allowFullScreen', '{0}');", true);
            sb.AppendLine();
            sb.AppendLine("so.setAttribute('xiRedirectUrl', window.location);");
            sb.AppendLine("so.write('flashcontent');");
            sb.Append("</script>");

            Response.Write(sb.ToString());
        }
    }
}